import apiConfig from "../apis/config.js"
//图片路径拼接
/**
 *图片路径拼接
 *@param {string} src 路径
 *@param {width} width 裁剪宽度
 *@param {height} height 裁剪高度
 *@returns {string} urls 补全路径
 */
export const imgUrl = (src, width, height) => {
	if (!src) {
		return ''
	}
	if ((src.indexOf('http') != -1 && !width && !height) || src.indexOf('/static') != -1) {
		return src
	}
	let urls = src
	if (src.indexOf('http') == -1) urls = apiConfig.imgURL + src
	if (!width || !height) return urls;
	if (!isNaN(Number(width)) && !isNaN(Number(height))) {
		if (src.indexOf('http') != -1) {
			urls += `?imageView2/1/w/${width}/h/${height}/q/100!`
		} else {
			urls = apiConfig.imgURL + src + `?imageView2/1/w/${width}/h/${height}/q/100!`
		}
		return urls
	}
	return urls
}
